package cc.fs.zhihuapp.ui.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;

import cc.fs.zhihuapp.R;

/**
 * Created by fostion on 2015/9/6.
 */
public class NewDetailsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    public static final int TYPE_WEBVIEW = 1;
    WebViewHolder holder;

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_webview, parent, false);
                holder = new WebViewHolder(v);
                return holder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

    }


    @Override
    public int getItemViewType(int position) {
        return TYPE_WEBVIEW;
    }

    @Override
    public int getItemCount() {
        return 1;
    }

    private class WebViewHolder extends RecyclerView.ViewHolder {
        WebView webView;

        public WebViewHolder(View itemView) {
            super(itemView);
            webView = (WebView) itemView.findViewById(R.id.webview);
            webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
            webView.getSettings().setJavaScriptEnabled(true);
        }
    }

    public WebView getWebView(){
        return holder.webView;
    }

}
